package com.base.component.app.push.core;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.base.component.app.push.bo.PushBO;
import com.gitee.magic.core.exception.ApplicationException;

@Component
public class PushHandlerTemplate<P extends PushBO>{
	
	@Autowired
	private List<PushHandler<P>> pushHandlers;
	
	public void push(P param) {
		for(PushHandler<P> p:pushHandlers) {
			if(p.support(param.getPlatform(),param.getClass())) {
				p.execute(param);
				return;
			}
		}
		throw new ApplicationException("push object is null param:"+param);
	}
	
}
